﻿
if not exists(select * from sysobjects where name = 'QuoteCart' and xtype = 'U')
Begin

CREATE TABLE [dbo].[QuoteCart](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[CreationDate] [datetime] NOT NULL,
	[VisitorId] [nvarchar](40) NOT NULL,
	[CartStateId] [int] NOT NULL,
	[CustomerPersonId] [int] NULL,
	[Message] [nvarchar](max) NULL,
	[CustomerDocumentReference] [nvarchar](100) NULL,
	[LastUpdate] [datetime] NOT NULL,
	[Code] [varchar](40) NOT NULL,
	[ConvertedEntityId] [int] NULL,
	[ConversionDate] [datetime] NULL,
	[LastPage] [nvarchar](255) NULL,
	[LeadSourceInfo] [varchar](512) NULL,
	[LeadSourceId] [varchar](50) NULL,
	[RevisionId] [timestamp] NOT NULL,
)

alter table QuoteCart add constraint PK_QuoteCart_Id primary key (Id)

create unique index IX_QuoteCart_Code on QuoteCart(code)

create index IX_QuoteCart_VisitorId on QuoteCart(VisitorId)

End
Go